package service;

import dao.EasyBuyDao;
import entity.User;
import utils.SecurityUtils;

public class EasyBuyService {
	public  EasyBuyDao esaDao = new EasyBuyDao();
	//验证用户名是否存在
	public int userName(String name){
		return esaDao.userName(name); 
	}
	//登录
	public User userDengle(String name2, String pass){
		int count = esaDao.userName(name2);
		//加密，使用注册时的密码
		String  md5Pwd2= null;
		if(count>0){
		      md5Pwd2 = SecurityUtils.md5Hex(pass);
		}
		return esaDao.userDengle(name2, md5Pwd2);  
	}
	//注册 和加密
	public boolean userAdd(User user){
		String md5Pwd = SecurityUtils.md5Hex(user.getPassword());
		user.setPassword(md5Pwd);
		return esaDao.userAdd(user)>0;
	}
}
